<template>
    <RouterView />
</template>

<script setup lang="ts">
import { ref, watch, onBeforeMount, computed } from "vue";
import { RouterView, useRoute } from 'vue-router';
import { reservationConfigDetail } from '@/request/api/reservationConfig';
import { useOrderStore } from '@/stores/order';
import { ticketDetail } from '@/request/api/ticket';
import router from '@/router';

const title = ref('选择参观日期');
const step = ref(1);
const route = useRoute();
const order = computed(() => {
    return useOrderStore().orderGetter;
})

watch(() => route.fullPath, () => {
    if (route.path != '/flow/calendar' && route.path != '/flow' && route.path != '/') {
        if (!order.value.visitDate || !order.value.visitPeriod) {
            router.replace('/');
        }
    } else {
        useOrderStore().resetOrder();
    }
    switch (route.path) {
        case '/flow/calendar':
            step.value = 1;
            break;
        case '/flow/fillinfo':
            step.value = 2;
            break;
        case '/flow/confirminfo':
            step.value = 3;
            break;
        case '/flow/complete':
            step.value = 4;
            break;
    }
}, { immediate: true })

onBeforeMount(() => {
    const type = 'copywritingManagement';
    reservationConfigDetail(type).then((res: any) => {
        useOrderStore().noticeReservation = res.data.noticeReservation;
        useOrderStore().statement = res.data.statement;
    })
    ticketDetail().then((res: any) => {
        useOrderStore().isCheck = res.data.isCheck;
    })
})

</script>

<style lang="scss" scoped></style>
